package stu.sup.controller.product;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import stu.sup.dto.PicDTO;
import stu.sup.entity.Product;
import stu.sup.service.IClassTableService;
import stu.sup.service.IProductService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller

public class IndexController {
    @Autowired
    private IClassTableService classTableService;
    @Autowired
    private IProductService productService;

    //查询所有商品
    @RequestMapping("index")
   public String index(Model model, HttpServletRequest request){
        Object name=request.getSession().getAttribute("loginUserName");

        model.addAttribute("name",name);
        List<PicDTO> picDTOS=productService.findAll();
        model.addAttribute("picDTO",picDTOS);
       List<PicDTO> friuts=productService.findbybrand("水果");
       model.addAttribute("fruits",friuts);
       List<PicDTO> seeAnimal=productService.findbybrand("海鲜");
       model.addAttribute("seeAnimal" ,seeAnimal);
       return "index";
    }


}
